/**
 * @FileDescription 首页api
 * @Author 祝小文
 * @CreateDate 2022-10-11 22:01
 */
import { chemical_server as request } from '@/service'

interface ResultType {
  result: {
    resultCode: string
    resultMessage: string
  }
  data: object
}

/** 适配接口返回结果 */
function adapter(response: ResultType) {
  if (response.result.resultCode == '000000') {
    return response.data
  }
  throw new Error()
}

//首页顶部数据获取
export const queryHomeList = (params?: any) =>
  request.get(`statistics/queryStatisticsHomeInfo`, { params }).then((res) => adapter(res as any))

//首页表格数据获取
export const queryQyxxInfoPage = (params?: any) =>
  request.get(`/qyxx/queryQyxxInfoPage`, { params }).then((res: any) => adapter(res as any))
//首页市、区县数据获取
export const querysqx = (params?: any) =>
  request.get(`/zd-zdmc/queryQyPageZdInfo`, { params }).then((res: any) => adapter(res as any))

export const  insertOrUpdateback= (params?: any) =>
  request.post(`/qycjzt/insertOrUpdate`, params ).then((res: any) => adapter(res as any))

export const  queryQycjztInfo= (params?: any) =>
  request.get(`/qycjzt/queryQycjztInfo`, {params} ).then((res: any) => adapter(res as any))
